#!/usr/bin/perl

use strict;
use FindBin qw($Bin);
use IO::Socket::INET;

my $default_memcache = "127.0.0.1:11211";
my $sock = IO::Socket::INET->new(PeerAddr => $default_memcache);
if ($sock) {
    print "Memcached running at $default_memcache\n";
    $ENV{MEMCACHE} = $default_memcache;
}

my @paths = grep { -r && -x _ } qw(
                                   /usr/bin/lighttpd
                                   /usr/sbin/lighttpd
                                   /usr/local/bin/lighttpd
                                   /usr/local/sbin/lighttpd
                                   );
die "lighttpd binary not found.  Not installed?\n" unless @paths;
my $lighttpd = $paths[0];

$ENV{OPENID_TEST_ROOT} = $Bin;
$ENV{MEMCACHE} ||= "0";
print "Will be running at:\n";
print "  http://127.0.0.1:9001/perl/perl-test.cgi\n";
exec("$lighttpd", "-f", "$Bin/lighttpd.conf", "-D");

